<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

$config = [
    'id' => 'app-frontend',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'frontend\controllers',
    'defaultRoute'=>'xcx',//设置项要默认的控制器就OK
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-frontend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => 'advanced-frontend',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            //'enableStrictParsing' => true,
            'rules' => [
                [
                    'pattern' => 'taokeapp',
                    'route' => 'taokeapp/index',
                    'suffix' => '.html',
                ],
                [
                    'pattern' => 'help/<id:\w+>',
                    'route' => 'help/index',
                    'suffix' => '.html',
                ],
                [
                    'pattern' => '<cat:\w+>/<id:\w+>',
                    'route' => 'word/index',
                    'suffix' => '.html',
                ],
                [
                    'pattern' => '<cat:\w+>/',
                    'route' => 'word/list',
                    'suffix' => '/',
                ],
                [
                    'pattern' => '<cat:\w+>/<page:\w+>',
                    'route' => 'word/list',
                    'suffix' => '/',
                ],
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
    ],
    'params' => $params,
];

if(\common\utils\Com::isM()){
    $config['components']['view'] = [
        'theme' => [
            'basePath' => '@frontend/themes/mobile',
            'baseUrl' => '@web/themes/mobile',
            'pathMap' => [
                '@app/views' => '@frontend/themes/mobile',
            ],
        ],
    ];
}
return $config;
